import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:ruida_bottom_demo/app/components/bottom4/bottom_app_bar_4.dart';

import '../controllers/bottom4_controller.dart';

class Bottom4View extends GetView<Bottom4Controller> {
  const Bottom4View({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('中间凹进去的菜单'),
        centerTitle: true,
      ),
      body: Stack(
        children: [
          content(),
          bottomBar(),
        ],
      ),
    );
  }

  Widget content() {
    return Positioned.fill(
      child: Container(
        alignment: Alignment.center,
        child: Obx(() {
          return Text(controller.pageIndex.value.toString(),
              style: TextStyle(color: Colors.grey[400], fontSize: 80));
        }),
      ),
    );
  }

  Widget bottomBar() {
    return Positioned(
        left: 0,
        right: 0,
        bottom: 0,
        child: BottomAppBar4(
            tabIconsList: controller.tabIconsList,
            centerClick: () {
              /// 按钮动画结束之后
              debugPrint('点击了中间按钮');
            },
            changeIndex: (index) {
              onClickBottomBar(index);
            }));
  }

  void onClickBottomBar(int index) {
    controller.changPageIndex(index);
  }
}
